{php include fx_template('common/header');}
<div class="page-group">
    <div class="page page-current" id="page-coupon-list">
    	<header class="bar bar-nav">
		    <a class="button button-link button-nav pull-left back" href="{php echo app_url('member/home')}">
		      <span class="icon icon-left"></span>返回
		    </a>
		    <h1 class="title">我的优惠券</h1>
		</header>
		<div class="content native-scroll">
		    <div class="buttons-tab">
		      <a href="#tab1" class="tab-link button active">未使用</a>
		      <a href="#tab2" class="tab-link button">已使用</a>
		      <a href="#tab3" class="tab-link button">已过期</a>
		    </div>
		    <div class="tabs">
		      <div id="tab1" class="tab active">
		      </div>
		      <div id="tab2" class="tab">
		      </div>
		      <div id="tab3" class="tab">
		      </div>
		    </div>
		</div>
	</div>
</div>
<script type="text/html" id="couponlist">
{{# for(var i = 0, len = d.length; i < len; i++){ }}
<div class="card" style="border-radius: .2rem;">
  <div class="card-content" style="border-radius: .2rem .2rem 0 0;color: white;{{# if(i%3 == 0){ }}background-color: #4dd6b1;{{# }else if(i%3 == 1){ }}background-color: #6eb3e8;{{# }else{ }}background-color: #ffb600;{{# } }}">
    <div class="list-block media-list">
      <ul>
      	<a class="external" href="{php echo app_url('member/coupon/detail')}id={{ d[i].id }}">
        <li class="item-content">
          <div class="item-media">
            <img src="{php echo tomedia($_W['_config']['tginfo']['slogo'])}" width="50" style="border-radius: 25px;">
          </div>
          <div class="item-inner">
            <div class="item-title-row">
              <div class="item-title">{{ d[i].name }}</div>
            </div>
            <div class="item-subtitle">￥ {{ d[i].cash }}</div>
          </div>
        </li>
        </a>
      </ul>
    </div>
  </div>
  <div class="card-footer">
    <span>截止时间：{{ d[i].end_time }}</span>
    <span style="display: flex;"><a href="{php echo app_url('member/coupon/detail')}id={{ d[i].id }}" class="weui_btn weui_btn_mini weui_btn_default external">查看详情</a></span>
  </div>
</div>
{{# } }}
</script>
<script>
$(function () {
  'use strict';
	$(document).on("pageInit", "#page-coupon-list", function(e, id, page) {
		var gettpl = document.getElementById('couponlist').innerHTML;
		var emphtml = '<div class="m-cart" id="s"><div class="empty" id="pro-view-6">暂无优惠券，<a href="{php echo app_url('goods/index')}" class="external">马上去逛逛~</a></div></div>';
		laytpl(gettpl).render({php echo json_encode($coupon3)}, function(html){
			if(html.length < 10){
				$("#tab1").append(emphtml);
			}else{
				$("#tab1").append(html);
			}
		});
		laytpl(gettpl).render({php echo json_encode($coupon1)}, function(html){
			if(html.length < 10){
				$("#tab2").append(emphtml);
			}else{
				$("#tab2").append(html);
			}
		});
		laytpl(gettpl).render({php echo json_encode($coupon2)}, function(html){
			if(html.length < 10){
				$("#tab3").append(emphtml);
			}else{
				$("#tab3").append(html);
			}
		});
	});
  $.init();
});
</script>
{php include fx_template('common/footer');}